/**
 * 
 */
package com.cplsystems.incidencias.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.cplsystems.incidencias.app.utils.HibernateDAOSuportUtil;
import com.cplsystems.incidencias.business.EstadoCivil;
import com.cplsystems.incidencias.dao.EstadoCivilDAO;

/**
 * @author César Palalía López (csr.plz@aisa-automation.com)
 * 
 */
@Repository
public class EstadoCivilDAOImpl extends HibernateDaoSupport implements
		EstadoCivilDAO {

	@Autowired
	public void init(final SessionFactory sessionFactory)
			throws DataAccessException {
		setSessionFactory(sessionFactory);
	}

	@SuppressWarnings("unchecked")
	public List<EstadoCivil> getAll() {
		List<EstadoCivil> estadosCiviles = getHibernateTemplate().find(
				"FROM EstadoCivil as e");
		return estadosCiviles.size() > 0 ? estadosCiviles : null;
	}

	@Transactional
	public void save(EstadoCivil nuevoEstadoCivil) {
		getHibernateTemplate().saveOrUpdate(nuevoEstadoCivil);
	}

	@Transactional
	public void delete(EstadoCivil estadoCivilForRemove) {
		getHibernateTemplate().delete(estadoCivilForRemove);
	}

}
